import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';

import 'videoPage.dart';

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  TextEditingController controller = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          children: <Widget>[
            SizedBox(height: 120,),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: TextField(
                keyboardType: TextInputType.number,
                controller: controller,
                decoration: InputDecoration(
                  hintText: "请输入频道",
                  labelText: "频道",
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(6),
                    gapPadding: 10
                  ),

                ),
              ),
            ),
            RaisedButton(
              color: Colors.blue,
              child: Container(height: 60,alignment: Alignment.center,margin: EdgeInsets.symmetric(horizontal: 20),
                child: Text("加入频道",style: TextStyle(color: Colors.white),),
              ),
              onPressed: ()async{
                PermissionHandler().requestPermissions([PermissionGroup.camera,PermissionGroup.microphone]).whenComplete((){
                  Navigator.push(context, MaterialPageRoute(builder: (_)=>VideoPage(channelName: controller.text)));
                });
                
              }
            )
          ],
        ),
      ),
    );
  }
}
